home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / KOOB / common / server / game.cs < prev    next >
Text File  |  2005-11-23  |  3KB  |  107 lines

  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine 
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5.  
  6. //-----------------------------------------------------------------------------
  7. // Invoked from the common server & mission loading functions
  8. //-----------------------------------------------------------------------------
  9.  
  10. function onServerCreated()
  11. {
  12.    // Invoked by createServer(), when server is created and ready to go
  13.  
  14.    // Server::GameType is sent to the master server.
  15.    // This variable should uniquely identify your game and/or mod.
  16.    $Server::GameType = "Test App";
  17.  
  18.    // Server::MissionType sent to the master server.  Clients can
  19.    // filter servers based on mission type.
  20.    $Server::MissionType = "Deathmatch";
  21.  
  22.    // Load up all datablocks, objects etc.  This function is called when
  23.    // a server is constructed.
  24.    // exec("./foo.cs");
  25.  
  26.    // For backwards compatibility...
  27.    createGame();
  28. }
  29.  
  30. function onServerDestroyed()
  31. {
  32.    // Invoked by destroyServer(), right before the server is destroyed
  33.    destroyGame();
  34. }
  35.  
  36. function onMissionLoaded()
  37. {
  38.    // Called by loadMission() once the mission is finished loading
  39.    startGame();
  40. }
  41.  
  42. function onMissionEnded()
  43. {
  44.    // Called by endMission(), right before the mission is destroyed
  45.    endGame();
  46. }
  47.  
  48. function onMissionReset()
  49. {
  50.    // Called by resetMission(), after all the temporary mission objects
  51.    // have been deleted.
  52. }
  53.  
  54.  
  55. //-----------------------------------------------------------------------------
  56. // These methods are extensions to the GameConnection class. Extending
  57. // GameConnection make is easier to deal with some of this functionality,
  58. // but these could also be implemented as stand-alone functions.
  59. //-----------------------------------------------------------------------------
  60.  
  61. function GameConnection::onClientEnterGame(%this)
  62. {
  63.    // Called for each client after it's finished downloading the
  64.    // mission and is ready to start playing.
  65.    // Tg: Should think about renaming this onClientEnterMission
  66. }
  67.  
  68. function GameConnection::onClientLeaveGame(%this)
  69. {
  70.    // Call for each client that drops
  71.    // Tg: Should think about renaming this onClientLeaveMission
  72. }
  73.  
  74.  
  75. //-----------------------------------------------------------------------------
  76. // Functions that implement game-play
  77. // These are here for backwards compatibilty only, games and/or mods should
  78. // really be overloading the server and mission functions listed ubove.
  79. //-----------------------------------------------------------------------------
  80.  
  81. //-----------------------------------------------------------------------------
  82.  
  83. function createGame()
  84. {
  85.    // This function is called by onServerCreated (ubove)
  86. }
  87.  
  88. function destroyGame()
  89. {
  90.    // This function is called by onServerDestroyed (ubove)
  91. }
  92.  
  93.  
  94. //-----------------------------------------------------------------------------
  95.  
  96. function startGame()
  97. {
  98.    // This is where the game play should start
  99.    // The default onMissionLoaded function starts the game.
  100. }
  101.  
  102. function endGame()
  103. {
  104.    // This is where the game play should end
  105.    // The default onMissionEnded function shuts down the game.
  106. }
  107.